home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Mathematics / Notebooks / SigProc2.0 / Packages / SignalProcessing / Digital / MDDTFT.m < prev    next >
Encoding:
Text File  |  1992-08-18  |  5.0 KB  |  165 lines

  1. (*  :Title:    Discrete-Time Fourier Transforms *)
  2.  
  3. (*  :Authors:    Brian Evans and James McClellan  *)
  4.  
  5. (*  :Summary:    To provide DTFT's not normally used by undergrads  *)
  6.  
  7. (*  :Context:    SignalProcessing`Digital`DTFT`     *)
  8.  
  9. (*  :PackageVersion:  2.7    *)
  10.  
  11. (*
  12.     :Copyright:    Copyright 1989-1991 by Brian L. Evans
  13.         Georgia Tech Research Corporation
  14.  
  15.     Permission to use, copy, modify, and distribute this software
  16.     and its documentation for any purpose and without fee is
  17.     hereby granted, provided that the above copyright notice
  18.     appear in all copies and that both that copyright notice and
  19.     this permission notice appear in supporting documentation,
  20.     and that the name of the Georgia Tech Research Corporation,
  21.     Georgia Tech, or Georgia Institute of Technology not be used
  22.     in advertising or publicity pertaining to distribution of the
  23.     software without specific, written prior permission.  Georgia
  24.     Tech makes no representations about the suitability of this
  25.     software for any purpose.  It is provided "as is" without
  26.     express or implied warranty.
  27.  *)
  28.  
  29. (*  :History:    begun and ended        June 18, 1992  *)
  30.  
  31. (*  :Keywords:    discrete-time Fourier transform  *)
  32.  
  33. (*
  34.     :Source:    {Discrete-Time Signal Processing} by A. V. Oppenheim and
  35.           Ronald W. Schafer.  Prentice Hall.  1989
  36.  *)
  37.  
  38. (*  :Warning:    *)
  39.  
  40. (*  :Mathematica Version:  1.2 or 2.0  *)
  41.  
  42. (*  :Limitation:  *)
  43.  
  44. (*
  45.     :Discussion:  This file implements the forward and inverse DTFT's
  46.           not normally requested by undergraduates.
  47.  *)
  48.  
  49. (*  :Functions:   *)
  50.  
  51.  
  52.  
  53. (*  B E G I N     P A C K A G E  *)
  54.  
  55. BeginPackage[ "SignalProcessing`Digital`MDDTFT`" ]
  56. EndPackage[]
  57.  
  58. BeginPackage[ "SignalProcessing`Digital`DTFT`",
  59.           "SignalProcessing`Digital`DSupport`",
  60.           "SignalProcessing`Digital`InvZTransform`",
  61.           "SignalProcessing`Digital`ZTransform`",
  62.           "SignalProcessing`Digital`ZSupport`",
  63.           "SignalProcessing`Support`TransSupport`",
  64.           "SignalProcessing`Support`ROC`",
  65.           "SignalProcessing`Support`SigProc`",
  66.           "SignalProcessing`Support`LatticeTheory`",
  67.           "SignalProcessing`Support`SupCode`" ]
  68.  
  69.  
  70. If [ TrueQ[ $VersionNumber >= 2.0 ],
  71.      Off[ General::spell ];
  72.      Off[ General::spell1 ] ];
  73.  
  74.  
  75. Begin[ "`Private`" ]
  76.  
  77.  
  78. (*  B E G I N     P A C K A G E  *)
  79.  
  80. postdownsamplemD[x_, w_, m_] :=
  81.     Block [    {cosets, factor, invmtrans, k, newx},
  82.         newx = posttransform[x];
  83.         cosets = 2 Pi DistinctCosetVectors[m];
  84.         factor = Abs[Det[m]];
  85.         invmtrans = Inverse[Transpose[m]];
  86.         Sum[ newx /.
  87.              ReplaceWith[ w, invmtrans . ( w - cosets[[k]] ) ],
  88.              {k, 1, factor} ] / factor ]
  89.  
  90. upsampleSetUp[l_, nvars_, x_, n_, w_, z_, options_, flag_ ] :=
  91.     Block [    {lnew, nnew, pos, trash, wnew},
  92.         {lnew, nnew, trash} =
  93.             ReorderResampling[l, nvars, nList];
  94.         pos = Flatten[ Map[Position[nList, #1]&, nnew] ];
  95.         wnew = wList[[pos]];
  96.         upsamplemD[ myDTFT[x, n, w, z, options, flag],
  97.                 Complement[nnew, {n}], wnew, Transpose[lnew] ] ]
  98.  
  99. downsampleSetUp[m_, nvars_, x_, n_, w_, z_, options_, flag_ ] :=
  100.     Block [    {mnew, nnew, pos, trash, wnew},
  101.         {mnew, nnew, trash} =
  102.             ReorderResampling[m, nvars, nList];
  103.         pos = Flatten[ Map[Position[nList, #1]&, nnew] ];
  104.         wnew = wList[[pos]];
  105.         downsamplemD[ myDTFT[x, n, w, z, options, flag],
  106.                   Complement[nnew, {n}], wnew, m ] ]
  107.  
  108.  
  109. (* Routines to find an upsampling matrix and the upsampled variables *)
  110.  
  111. linearlyCoupledVariables[ x_, wlist_ ] :=
  112.     Block [ {dims, i, newx, varlist},
  113.         varlist = {};
  114.         dims = Length[wlist];
  115.         newx = Collect[ExpandAll[x], wlist];
  116.                 For [ i = 1, i <= dims, i++,
  117.               wvar = wlist[[i]];
  118.               goodvar = True;
  119.               newx /.
  120.             ( a_ wvar :> Block [ {}, goodvar = False; a wvar ] /;
  121.               goodvar && ! MyFreeQ[a, wlist] );
  122.               If [ goodvar, AppendTo[varlist, wvar] ] ];
  123.         varlist ]
  124.  
  125. upsampleSystem[ x_, upvarlist_ ] := UpsampledSystem[x, upvarlist]
  126.  
  127. upsampleSystemQ[ x_, upvarlist_ ] :=
  128.     Block [    {upmatrixtrans, wvars},
  129.         {upmatrixtrans, wvars} = upsampleSystem[x, upvarlist];
  130.         TrueQ[ Length[wvars] >= 2 ] && 
  131.         ! SameQ[ ResamplingMatrix[upmatrixtrans], False ] ]
  132.  
  133. undoUpsampling[ x_, w_, n_, z_, options_, flag_ ] :=
  134.     Block [    {newx, nvars, pos, trace, upmatrixtrans, wvars},
  135.         trace = SameQ[ Replace[Dialogue, options], All ];
  136.         wvars = linearlyCoupledVariables[x, wList];
  137.         {upmatrixtrans, wvars} = upsampleSystem[x, wvars];
  138.         If [ trace,
  139.              Print["( after noticing that the DTFT is a function of"]; 
  140.              Print["  ", upmatrixtrans, " . ", wvars, " = ",
  141.                upmatrixtrans . wvars ];
  142.              Print["  although the matrix is unique only to within"];
  143.              Print["  a permutation of the rows )" ] ];
  144.         pos = Flatten[ Map[Position[wList, #1]&, wvars] ];
  145.         nvars = nList[[pos]];
  146.         newx = x /. ReplaceWith[wvars, Inverse[upmatrixtrans] . wvars];
  147.         Upsample[ Transpose[upmatrixtrans], nvars ] [
  148.           myinvDTFT[ SPSimplify[newx], w, n, z, options, flag ] ] ]
  149.  
  150.  
  151. (*  E N D     P A C K A G E  *)
  152.  
  153. End[]
  154. EndPackage[]
  155.  
  156. If [ TrueQ[ $VersionNumber >= 2.0 ],
  157.      On[ General::spell ];
  158.      On[ General::spell1 ] ];
  159.  
  160.  
  161. (*  E N D I N G     M E S S A G E  *)
  162.  
  163. Print["Special multidimensional DTFT rules have been loaded."]
  164. Null
  165.